package com.teach.flavour.enums;

import com.common.utils.IBaseEnum;

import java.util.Arrays;
import java.util.Optional;

/**
 * @author hzz
 */

public enum MealSubstituendum implements IBaseEnum {
    SHAOKAO(1, "烧烤"),
    TIANDIAN(2, "甜点"),
    MALATANG(3, "麻辣烫"),
    OTHER(4, "其他");

    private Integer value;
    private String text;

    MealSubstituendum(int value, String text) {
        this.value = value;
        this.text = text;
    }
    public synchronized static MealSubstituendum fromCode(Integer code) {
        if (null != code) {
            Optional<MealSubstituendum> optional = Arrays.asList(MealSubstituendum.values()).stream().filter(x -> x.getValue() - code == 0).findAny();
            return optional.isPresent() ? optional.get() : null;
        }

        return null;
    }
    public synchronized static MealSubstituendum textOf(String text) {
        if (null != text) {
            Optional<MealSubstituendum> optional = Arrays.asList(MealSubstituendum.values()).stream().filter(x -> x.getText().equals(text) ).findAny();
            return optional.isPresent() ? optional.get() : null;
        }

        return null;
    }
    @Override
    public int getValue() {
        return this.value;
    }

    @Override
    public String getText() {
        return this.text;
    }

    @Override
    public String paraString() {
        return this.paraString();
    }
}
